package com.OrderingSystem.pojo;

import java.math.BigDecimal;

import com.baomidou.mybatisplus.annotation.*;

import java.time.LocalDateTime;
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "product_info")
@Api(value = "商品信息")
@JsonPropertyOrder({
        "productId", "productName", "productPrice", "productStock",
        "productDescription", "productIcon", "productStatus",
        "categoryType", "createTime", "updateTime"
}) // 指定返回的属性顺序
public class ProductInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "product_id", type = IdType.AUTO)
    @ApiModelProperty(value = "商品ID", required = true, example = "1")
    private Integer productId;

    @ApiModelProperty(value = "商品名称", required = true, example = "鱼香肉丝")
    private String productName;

    @ApiModelProperty(value = "商品单价", required = true, example = "20.00")
    private BigDecimal productPrice;

    @ApiModelProperty(value = "商品库存", required = true, example = "10")
    private Integer productStock;

    @ApiModelProperty(value = "商品描述", example = "鱼香肉丝是一道传统的汉族名菜")
    private String productDescription;

    @ApiModelProperty(value = "商品小图", example = "https://www.baidu.com//1.jpg")
    private String productIcon;

    @ApiModelProperty(value = "商品状态,0正常,1下架", required = true, example = "0")
    private Integer productStatus;

    @ApiModelProperty(value = "类别编号", required = true, example = "1")
    private Integer categoryType;

    @ApiModelProperty(value = "创建时间", required = true, example = "2020-01-01 00:00:00")
    @TableField(value = "create_time", fill = FieldFill.INSERT) //插入时自动填充创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "修改时间", required = true, example = "2020-01-01 00:00:00")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) //插入和更新时自动填充修改时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @Override
    public String toString() {
        return "ProductInfo{" +
            "productId=" + productId +
            ", productName=" + productName +
            ", productPrice=" + productPrice +
            ", productStock=" + productStock +
            ", productDescription=" + productDescription +
            ", productIcon=" + productIcon +
            ", productStatus=" + productStatus +
            ", categoryType=" + categoryType +
            ", createTime=" + createTime +
            ", updateTime=" + updateTime +
        "}";
    }
}
